#GraphNodePinControlIn
#GraphNodePinControlOut
#GraphLinkWidget
#GraphMagnetWidget
#GraphTreeWidget

# Interactive GUI client providing the following features:
#	* Data and control modeling
#	* Configuration managment
#	* Distributed deployment
#	* Local and remote debugging, profiling and testing
#	* Rule DSL editor
#	* Interactive graph editing and algorithm analysis
class StackMapper(Canvas):

	def __init__(self, master):
		Canvas.__init__(self, master, width=800, height=600)
		self.pack()
		
		# Mouse Event bindings
		self.bind("<Button-1>", self.button_1)
		self.bind("<Button-2>", self.button_2)
		self.bind("<Enter>", self.enter)
		self.bind("<Leave>", self.leave)
		self.bind("<B1-Motion>", self.button_1_motion)	
		self.bind("<ButtonRelease-1>", self.button_1_release)			
		self.bind("<Configure>", self.changed_size)

		# Menu Frame
		self.menu = Menu(master)
		master.config(menu=self.menu)		
		# Menu - File
		self.menu.file = Menu(self.menu)
		self.menu.add_cascade(label="File", menu=self.menu.file)
		#self.menu.file.add_command(label="New")
		# Menu - File - New
		self.menu.file.new = Menu(self.menu.file)
		self.menu.file.add_cascade(label="New", menu=self.menu.file.new)
		self.menu.file.new.add_command(label="Stack", command=self.file_new)
		self.menu.file.new.add_command(label="Model", command=self.file_new)			
		self.menu.file.add_separator()
		self.menu.file.add_command(label="Open ...", command=self.file_open)
		self.menu.file.add_command(label="Open Stack", command=self.file_open)
		self.menu.file.add_command(label="Open Model", command=self.file_open)				
		# Meny - Help
		self.menu.help = Menu(self.menu)	
		self.menu.add_cascade(label="Help", menu=self.menu.help)
		self.menu.help.add_command(label="About", command=self.help_about)

	# new .stack file to contain
	def file_new(self):
		print "<File-New>"
		# create new .stack file
		# create new project structure
		#	look for user templates
		#	appy user user templates to default project
		# pickle stack to .stack

	def file_open(self):
		print "<File-Open>"
		#self.file_dialog.askopenfile(parent=master, mode="rb", title="File select")

	def help_about(self):
		print "<Help-About>"

	def button_1(self, event):
		print "<Button-1> x:", event.x, " y:", event.y
	
	def button_1_motion(self, event):
		print "<Button-1-Motion> x:", event.x, " y:", event.y
	
	def button_1_release(self, event):
		print "<Button-1-Release> x:", event.x, " y:", event.y
	
	def button_2(self, event):
		print "<Button-2> x:", event.x, " y:", event.y

	def enter(self, event):
		print "<Enter> x:", event.x, " y:", event.y
	
	def leave(self, event):
		print "<Leave> x:", event.x, " y:", event.y

	def changed_size(self, event):
		print "<Change-Size> w:", event.width, " h:", event.height

#class FileMenu:

#class HelpMenu:

root = Tk()
app = StackMapper(master=root)		
app.master.title("StackMapper")
app.mainloop()